#!/bin/bash

error_exit(){
	echo "ERROR $1"
	exit 1
}

rootPath=$1
pass=$2
ip=$3
cmd=$4

expect ${rootPath}/shell/validate_ssh.sh ${ip} root > /dev/null || error_exit
source /etc/profile && sshpass -p ${pass} ssh root@${ip} "source /etc/profile && ${cmd}" > /dev/null || error_exit
exit 0